// record.js
var app = getApp()
//常量数据配置
var ConstantData = require('../../../../common/constant_data.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    timeList:[],
    numPerPage:20,
    pageNum:1,
    userTime:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this

    app.executeRequest(function (header) {

      wx.request({
        url: ConstantData.CONSTATNT_DATA.BASE_URL + '/lease_time_card/records',
        header: header,
        data: {
          pageNum: that.data.pageNum,
          numPerPage: that.data.numPerPage
        },
        success: function (res) {
          console.log("time_card buy record ------")
          console.log(res)
          var data = res.data
          var result = data.result
          if (result != 0) {
            var desc = data.description
            wx.showToast({
              title: desc + '(' + result + ')',
            })
            return
          }
          console.log(data)
          var page = data.data.page
          var currentUserTime = data.data.userCardTime[0]
          that.setData({
            timeList: page.data,
            numPerPage: page.numPerPage,
            pageNum: page.pageNum,
            userTime: currentUserTime
          })
        },
        fail: function (res) {
          wx.showToast({
            title: '网络异常,稍后重试',
          })
        }
      })

    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }

})